// pages/shop/send.js
var app = getApp();
var orderId = 0;

Page({
  data: {
    onSubmit: false
  },
  onLoad: function (options) {
    orderId = options.id;
    console.log(orderId);
  },
  save: function(e){
    var that = this;
    if (this.data.onSubmit) {
      return false
    } else {
      this.setData({
        onSubmit: true
      })
    }
    wx.showLoading({
      title: '提交中',
      mask: true
    })
    var exp_no = e.detail.value.exp_no;
    var exp_company = e.detail.value.exp_company;
    app.func.req('orders/express', {
      id: orderId,
      exp_no: exp_no,
      exp_company: exp_company
    }, 'POST', function (res) {
      console.log(res);
      wx.hideLoading();
      if (res.code == 'success') {
        wx.showToast({
          title: '发货成功',
          duration: 2000,
          mask: true,
          success: function(){
            wx.navigateBack();
          }
        });
      } else {
        wx.showToast({
          title: '提交失败',
          image: '/images/fail.png',
          duration: 2000
        });
      }
      that.setData({
        onSubmit: false
      })
    }, {
      'token': wx.getStorageSync('token')
    });
  }
})
